﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using HRM.DAL.DAO;

namespace HRM.DAL.Gateway
{
    public class RoleGateway:DBGateway
    {
        public List<Role> GetRoles()
        {
            try
            {
                ConnectionObj.Open();
                CommandObj.CommandText = "select * from tblUserRole";
                SqlDataReader reader = CommandObj.ExecuteReader();
                List<Role> roles=new List<Role>();
                while (reader.Read())
                {
                    Role role=new Role();
                    role.Id = Convert.ToInt32(reader[0]);
                    role.RoleNme = reader[1].ToString();
                    roles.Add(role);
                }
                return roles;
            }
            catch (Exception ex)
            {
                throw new Exception("Error occured while retriving Roles", ex);
            }
            finally
            {
                ConnectionObj.Close();
            }
        }
    }
}